package com.flong.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.flong.config.DynamicTaskSchedule;
import com.flong.entity.TaskCron;
import com.flong.mapper.ICronMapper;

@Controller
@SuppressWarnings("all")
public class TaskTimeController {
	
	
	@Autowired private ICronMapper cronMapper;
	@Autowired private DynamicTaskSchedule dynamicTaskSchedule;
	
	@ResponseBody
	@RequestMapping("/taskScheduleConfig")
	public String taskScheduleConfig() {
		
		int ret = cronMapper.update(new TaskCron(1, "0/10 * * * * ?"));
		return "Success,"+ret;
	}
	
	
	@ResponseBody
	@RequestMapping("/startTaskSchedule")
	public String startTaskSchedule() {
		
		/**根据表达式进行启动*/
		dynamicTaskSchedule.startTask(new TaskCron("0/10 * * * * ?"));
		
		return "start Success";
	}
	
	

	@ResponseBody
	@RequestMapping("/stopTaskSchedule")
	public String stopTaskSchedule() {
		dynamicTaskSchedule.stopTask();
		return "stop Success";
	}
	
	


}